package com.sline.exception;

public class Demo2_Exception {
    public static void main(String[] args) {
        /*
        * 异常处理的两种方式
            * a: try...catch...finally
                * try catch
                * try catch finally
                * try finally
            try: 用来检测异常;
            catch: 用来捕获异常;
            finally: 释放资源;

            当通过trycatch将问题处理了, 程序将继续执行

            * b: throws
        */

        Demo2 d = new Demo2();
        try {
            int x = d.div(10, 0);
            System.out.println(x);
        } catch (ArithmeticException a) {       // ArithmeticException a = new ArithmeticException();
            System.out.println("除数出错了, 为0");
        }
    }
}

class Demo2 {
    public int div(int a, int b) {
        return a / b;
    }
}
